<div>
    <div class="col-lg-12">
        <section class="panel">
            <div class="panel-body">
                <form class="form-horizontal adminex-form" onsubmit="return false;">
                    <div class="base">
                        <div class="base-left">
                            <div class="form-group">
                                <label class="col-sm-3 control-label"><span class="red-start">*</span> 小组类型</label>
                                <div class="col-sm-4">
                                    <select name="type"  id='type' class="form-control" disabled>
                                        <?php foreach ($this->typeArr as $key => $item){?>
                                        <option value="<?php echo $key;?>" <?php if($this->thisInfo['type'] == $key) echo 'selected';?>><?php echo $item;?></option>
                                    <?php }?>
                                    </select>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label"><span class="red-start">*</span> 场次</label>
                                <div class="col-sm-4">
                                    <input type="number" class="form-control" disabled name="play_number" value="<?php echo $this->thisInfo['play_number'];?>" min="1"/>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">参赛球队A</label>
                                <div class="col-sm-4">
                                    <select name="player_a" disabled id='player_a' class="form-control">
                                        <option value="0">请选择</option>
                                        <?php foreach ($this->playerArr as $key => $item){?>
                                            <option value="<?php echo $key;?>" <?php if($this->thisInfo['player_a'] == $key) echo 'selected';?>><?php echo $item['player_name'];?></option>
                                        <?php }?>
                                    </select>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">参赛球队B</label>
                                <div class="col-sm-4">
                                    <select name="player_b" disabled id='player_b' class="form-control">
                                        <option value="0">请选择</option>
                                        <?php foreach ($this->playerArr as $key => $item){?>
                                            <option value="<?php echo $key;?>" <?php if($this->thisInfo['player_b'] == $key) echo 'selected';?>><?php echo $item['player_name'];?></option>
                                        <?php }?>
                                    </select>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label"><span class="red-start">*</span> 比赛开始时间</label>
                                <div class="col-sm-4">
                                    <input type="text" disabled class="form-control laydate-icon" value="<?php echo $this->thisInfo['start_time'];?>" id="start_time" name="start_time"/>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label"><span class="red-start">*</span> 竞猜开放时间</label>
                                <div class="col-sm-4">
                                    <input type="text" class="form-control laydate-icon" value="<?php echo $this->thisInfo['open_time'];?>" id="open_time" name="open_time"/>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label"><span class="red-start">*</span> 竞猜截止时间</label>
                                <div class="col-sm-4">
                                    <input type="text" class="form-control laydate-icon" value="<?php echo $this->thisInfo['stop_time'];?>" id="stop_time" name="stop_time"/>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">比分</label>
                                <div class="col-sm-2">
                                    <input type="number" class="form-control" name="score_a" value="<?php echo $this->thisInfo['score_a'];?>"/>
                                </div>
                                <div class="col-sm-2">
                                    <input type="number" class="form-control" name="score_b" value="<?php echo $this->thisInfo['score_b'];?>"/>
                                </div>
                            </div>
                            <div class="form-group">
                                <div class="modal-footer" style="text-align: left;margin-left: 6%;">
                                    <button class="btn btn-success" type="button"  onclick="subSave()">更新</button>
                                    <button class="btn btn-default" type="button" style="background-color:#CCCCCC;border-color:#CCCCCC;" data-dismiss="modal" aria-hidden="true">
                                        <a href="#" onclick="window.history.back()" style="text-decoration: none;">取消</a></button>
                                </div>
                            </div>
                        </div>
                    </div>
                </form>
            </div>
        </section>
    </div>
</div>

<script>
    laydate({
        elem: "#start_time",
        format: 'YYYY-MM-DD hh:mm:ss', //日期格式
        istime: true, //是否开启时间选择
        event: "focus"
    });
    laydate({
        elem: "#open_time",
        format: 'YYYY-MM-DD hh:mm:ss', //日期格式
        istime: true, //是否开启时间选择
        event: "focus"
    });
    laydate({
        elem: "#stop_time",
        format: 'YYYY-MM-DD hh:mm:ss', //日期格式
        istime: true, //是否开启时间选择
        event: "focus"
    });
    function subSave() {
        var score_a = $("input[name='score_a']").val();
        var score_b = $("input[name='score_b']").val();
        var open_time = $("#open_time").val();
        var stop_time = $("#stop_time").val();

        if(open_time === ''){
            layer.alert('请选择竞猜开放时间');
            return false;
        }
        if(stop_time === ''){
            layer.alert('请选择竞猜截止时间');
            return false;
        }
        var index = layer.msg('保存中...', {icon: 16,shade: [0.5, '#f5f5f5'],scrollbar: false,offset: '0px', time:1000000});
        $.ajax({
            url  : '/play/showing-edit?id=<?php echo $this->thisInfo['id'];?>',
            type : 'post',
            data : {
                score_a:score_a,
                score_b:score_b,
                open_time:open_time,
                stop_time:stop_time
            },
            dataType : 'json',
            success : function (msg) {
                if (msg.code == 200) {
                    layer.close(index);
                    layer.alert('更新成功',function () {
                        //location.href = '/play/setting';
                        window.location.reload();
                    })
                } else{
                    layer.close(index);
                    layer.alert('更新失败');
                }
            }
        });
    }
</script>